﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LabChecker.Client.CheckServiceReference;
using LabChecker.Models;

namespace LabChecker.Client
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var checkHelper = new CheckHelper();

            checkHelper.CheckStarted += (s, a) =>
            {
                browser.InvokeScript("DisplayCheckStart");
            };

            checkHelper.CheckCompleted += (s, a) =>
            {
                var checkResult = a.Result;
                browser.InvokeScript("DisplayResults", checkResult.TestCaseNumber, checkResult.Result, checkResult.Message);
            };

            browser.ObjectForScripting = checkHelper;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Task task;
            var checkService = new CheckServiceClient();
            checkService.Open();
            checkService.Close();

            var service1 = new CheckServiceClient();
            task = service1.GetTask(10);   

            using (var service = new CheckServiceClient())
            {
                task = service.GetTask(10);
                //var test = service.Test("Dennis");
            }
        }        
    }
}
